﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLCH_ANUONG.Forms
{
    public partial class frmCaiDatQuyen : Form
    {
        public frmCaiDatQuyen()
        {
            InitializeComponent();
            string strTag = Convert.ToString(this.Tag);
            clsMain.flexConn.InitForms(strTag, ref fcListView);
        }

        private void butCapNhat_Click(object sender, EventArgs e)
        {
            string strUserCode = "";
            string strSyschildCode = "";
            string strSQL = "";
            strUserCode = fcListView.strTextBoxCode;

            foreach (ListViewItem item in fcListView.lsv.Items)
            {

                if (item.Checked == true)
                {
                    strSyschildCode = Convert.ToString(item.Tag);
                    strSQL = "exec proc_save_quyennguoidung 2, ";
                }
                else
                {
                    strSyschildCode = Convert.ToString(item.Tag);
                    strSQL = "exec proc_save_quyennguoidung 1, ";
                }
                char[] delimiters = new char[] { ' ' };
                delimiters = new char[] { ' ' };
                string[] strSplit = strSyschildCode.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                strSQL = strSQL + "'" + strUserCode + "'," + "'" + strSplit[0] + "'";
                ADODB.Recordset Rs = new ADODB.Recordset();
                Rs.Open(strSQL, clsMain.flexConn.fcConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1);
                
            }
        }

        private void frmCaiDatQuyen_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.Equals(System.Windows.Forms.Keys.Escape))
            {
                this.Visible = false;
            }
        }

        private void frmCaiDatQuyen_Load(object sender, EventArgs e)
        {

        }
    }
}
